<template>
  <div class="searchContent">
    <div class="dzb" v-if="org.length">
      <div class="title">党支部</div>
      <ul class="children">
        <li v-for="(item, index) in org" :key="index">
          <img class="select" src="@as/img/select_r.png" alt="">
          <span class="name" @click="getOrgList(item.id)">{{item.name}}</span>
          <span class="people" @click="goMember(item.id,item.count)">{{item.count}}人</span>
        </li>
      </ul>
    </div>
    <div class="bg" v-if="org.length&party.length"></div>
    <div class="dy" v-if="party.length">
      <div class="title">党员</div>
      <ul class="memberList">
        <li @click="goInfo(item.id)" v-for="(item,index) in party" :key="index">
          <img :src="item.photo" alt="">
          <span>{{item.name}}</span>
        </li>
      </ul>
    </div>
  </div>
</template>

<script>
export default {
  data () {
    return {
      org:[],
      party:[]
    }
  },
  created() {
    console.log(this.$route.query.value)
    this.get()
  },
  methods: {
    goMember(id,count){
      if(count){
        this.$router.push({path: '/mine/memberList', query: {id:id}})
      } else {
        this.$toast.error('该组织暂无成员!');
      }
    },
    goInfo(id){
      this.$router.push({path: '/mine/memberInfo',query: {id:id}})
    },
    getOrgList(id){
      const url = `app/Party/index`
      let params = {
        org_ID: id
      }
      this.$http.get(url, params).then(res=>{
        if(res.data.list.length) {
          this.$router.push({path: '/mine/PartyMemberManagement',query: {id:id}})
        } else {
          this.$toast.error('该组织暂无下级!');
        }
      })
    },
    get(){
      const url = `app/Party/search`
      let params = {
        name : this.$route.query.value 
      }
      this.$http.get(url, params).then(res =>{
        this.org = res.data.org
        this.party = res.data.party
      })
    }
  },
  components: {

  }
}
</script>

<style lang="scss" scoped>
.searchContent{
  box-sizing: border-box;
  padding-top: 14px;
  .title{
    box-sizing: border-box;
    padding: 0 17px;
    position: relative;
    font-size:18px;
    line-height: 18px;
    height: 18px;
    font-family:PingFang-SC-Bold;
    font-weight:bold;
    color:rgba(51,51,51,1);
    margin-bottom: 9px;
    &::after{
      right: 17px;
      bottom: 50%;
      transform: translateY(-50%);
      position: absolute;
      content:'';
      width:283px;
      height:1PX;
      background:rgba(238,238,238,1);
    }
  }
  .children{
    box-sizing: border-box;
    padding-left: 16px;
    li{
      display: flex;
      justify-content: space-between;
      align-items: center;
      box-sizing: border-box;
      height: 52px;
      line-height: 52px;
      border-bottom: 1PX solid rgba(221,221,221,.5);
      padding-left: 26px;
      padding-right: 16px;
      &:last-of-type{
        border:0
      }
      span.name{
        display: inline-block;
        width: 230px;
        font-size:15px;
        font-family:PingFang-SC-Medium;
        font-weight:500;
        color:rgba(51,51,51,1);
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
      }
      .select{
        width:6px;
        height:10px;
        margin-right: 8px;
      }
      span.people{
        width:66px;
        height:21px;
        line-height: 21px;
        border:1px solid rgba(244,117,72,1);
        border-radius:10px;
        text-align: center;
        font-size:12px;
        font-family:PingFang-SC-Medium;
        font-weight:500;
        color:rgba(244,117,72,1);
      }
    }
  }
  .memberList{
    width: 100%;
    box-sizing: border-box;
    padding-left: 34px;
    li{
      display: flex;
      width: 100%;
      box-sizing: border-box;
      height: 70px;
      line-height: 70px;
      border-bottom: 1PX solid rgba(221,221,221,.5);
      padding-left: 8px;
      align-items: center;
      &:last-of-type{
        border:0
      }
      img{
        width:40px;
        height:40px;
        background:rgba(238,238,238,1);
        border-radius:50%;
        margin-right: 16px;
      }
      span{
        font-size:15px;
        font-family:PingFang-SC-Medium;
        font-weight:500;
        color:rgba(51,51,51,1);
      }
    }
  }
  .dzb,.dy{
    padding-top: 20px;
  }
  .bg{
    width:100%;
    height:10px;
    background:rgba(242,242,242,1);
  }
}
</style>
